< previous page page_903 next page >

Page 903
    cDBName = ""
    cDB = ""
    cSQV = ""
    intGlobalErr = False ' reset
    '
End Sub
Most of the code is self-explanatory. Notice that there is logic to determine whether the user should see any visual displays. This is here because you may want to run this generator as part of the OLE object model and do not need to see the SQLVBMain form.
The AutoGenDBOpen Method
Next, add the AutoGenDBOpen routine from Listing A.29. This opens the MDB.
Type.gifListing A.29. Coding the AutoGenDBOpen subroutine.
Public Sub AutoGenDBOpen(Optional cDB As Variant)
    On Error GoTo AutoGenDBOpenErr
    '
    If IsMissing(cDB) = True Or Len(cDB) = 0 Then
        SQLVBMain.CommonDialog1.DialogTitle = "Load MDB File"
        SQLVBMain.CommonDialog1.DefaultExt = "MDB"
        SQLVBMain.CommonDialog1.Filter = "MS Jet Database File|*.MDB"
        SQLVBMain.CommonDialog1.Flags = cdlOFNFileMustExist
        SQLVBMain.CommonDialog1.CancelError = True
        SQLVBMain.CommonDialog1.ShowOpen
        cDBName = SQLVBMain.CommonDialog1.filename
    Else
        cDBName = cDB
    End If
    '
    If Len(cDBName) = 0 Then
        intGlobalErr = True
    Else
        cDBName = Trim(cDBName)
        Set objDB = OpenDatabase(cDBName)
    End If
    GoTo AutoGenDBOpenExit
    '
AutoGenDBOpenErr:
    If Err <> 32755 Then
        ErrMsg Err, Error$, intLine, strLine, "AutoGenDBOpen"
    End If
    intGlobalErr = True
    '
AutoGenDBOpenExit:
End Sub

 
< previous page page_903 next page >

If you like this book, buy it!